import Cookies from 'js-cookie'

const TOKEN = 'RECRUIT_TEMPLATE_TOKEN'
const USER = 'RECRUIT_TEMPLATE_USER'
const USERTYPE = 'RECRUIT_TEMPLATE_USERTYPE'


// getDayTime
function getDayTime(day) {
  return new Date(new Date().getTime() + day * 24 * 60 * 60 * 1000);
}

// Token
export function setToken(token) { return Cookies.set(TOKEN, token) }

export function getToken() { return Cookies.get(TOKEN) }

// user
export function setUser(user, day) { 
  return day ? Cookies.set(USER, user, {expires: getDayTime(day)}) : Cookies.set(USER, user) 
}

export function getUser() { return Cookies.get(USER) }

// userType
export function setUserType(type) { return Cookies.set(USERTYPE, type) }

export function getUserType() { return Cookies.get(USERTYPE) }

// removeUser
export function removeUser() { return Cookies.remove(USER) }

